﻿using Echart.Model.Data;
using Echart.Model.Emphasis;
using Echart.Model.ItemStyle;
using Echart.Model.Legend;
using Echart.Model.Option;
using Echart.Model.Series;
using Echart.Model.TiTle;
using Echart.Model.ToolTip;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Echart.BLL.Echarts
{
    public class SampleManager
    {     
        /// <summary>
        /// 根据示例进行处理
        /// </summary>
        /// <returns></returns>
        public option CreateSample(string sampleName)
        {
            option opt = new option();
            switch (sampleName)
            {
                case "Referer_Web":
                    opt = sample_5();
                    break;
            }
            return opt;
        }

        private option sample_5()
        {
            title title = new title();
            title.text = "某站点用户访问来源";
            title.subtext = "纯属虚构";
            title.left = "center";

            tooltip tooltip = new tooltip();
            tooltip.trigger = "item";
            tooltip.formatter = "{a} <br/>{b} : {c} ({d}%)";

            legend legend = new legend();
            legend.orient = "vertical";
            legend.left = "left";
            string[] data = new string[5];          
            data[0] = "直接访问";
            data[1] = "邮件营销";
            data[2] = "联盟广告";
            data[3] = "视频广告";
            data[4] = "搜索引擎";           
            legend.data = data;

            series series = new series();
            series.name = "访问来源";
            series.type = "pie";
            string[] value = new string[2] { "0", "55%" };
            series.radius = value;
            string[] center = new string[2] { "50%", "60%" };
            series.center = center;
            data[] dataList = new data[5];
            dataList[0] = new data();
            dataList[1] = new data();
            dataList[2] = new data();
            dataList[3] = new data();
            dataList[4] = new data();
            dataList[0].value = 335;
            dataList[1].value = 310;
            dataList[2].value = 234;
            dataList[3].value = 135;
            dataList[4].value = 1548;
            dataList[0].name = "直接访问";
            dataList[1].name = "邮件营销";
            dataList[2].name = "联盟广告";
            dataList[3].name = "视频广告";
            dataList[4].name = "搜索引擎";
            series.data = dataList;
            emphasis emphasis = new emphasis();
            itemStyle itemStyle = new itemStyle();
            itemStyle.shadowBlur = 10;
            itemStyle.shadowOffsetX = 0;
            itemStyle.shadowColor = "rgba(0, 0, 0, 0.5)";
            emphasis.itemStyle = itemStyle;
            series.emphasis = emphasis;

            option option = new option();
            option.series = series;
            option.legend = legend;
            option.tooltip = tooltip;
            option.title = title;

            return option;
        }
    }
}
